package com.floreo.shopping.service;


import com.floreo.shopping.model.Group;
import com.floreo.shopping.model.Product;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @author merzod
 */
public class ProductServiceTest {

    private IProductService service;

    @Before
    public void setUp() throws Exception {
        service = ServiceFactory.getInstance().getProductService();
    }

    @Test
    public void testRegisterProduct() throws Exception {
        Group g1 = new Group();
        Group g2 = new Group();
        Product product1 = new Product("milk", g1);
        Product product2 = new Product("bread", g2);
        Product product3 = new Product("bublic", g2);
        service.registerProduct(product1);
        service.registerProduct(product2);
        service.registerProduct(product3);
        Assert.assertEquals(product1, service.getProductByName("milk"));
        Assert.assertEquals(product2, service.getProductByName("bread"));
        Assert.assertEquals(product3, service.getProductByName("bublic"));
    }
}
